package com.atguigu.config;

import com.atguigu.pojo.Animal;
import com.atguigu.pojo.Monkey;
import com.atguigu.pojo.Tiger;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

@Configuration

public class Aconfig {
    @Bean
    @ConditionalOnProperty(name = "com.atguigu.type",havingValue = "T")
    public Animal createAnimal() {
        return new Tiger();
    }
    @Bean
    @ConditionalOnProperty(name = "com.atguigu.type",havingValue = "M")
    public Animal createAnimal2() {
        return new Monkey();
    }
}
